package com.example.hcbmsm.controller;

import com.example.hcbmsm.domain.Doc;
import com.example.hcbmsm.service.DocService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @author Xinghm
 * @version 1.0
 * @since 2024/10/29 22:52
 */
@RestController
@CrossOrigin
@RequestMapping("/doc")
public class DocController {
    @Autowired
    private DocService docService;
    @GetMapping("/listByDeptId")
    public Map findDocByDeptId(Long deptId){
        return docService.findDocByDeptId(deptId);
    }

    @PostMapping("/getUser")
    public Map getUser(String token) {
        return docService.getUser(token);
    }

    @GetMapping("/list")
    public Map list(String docName, int page, int limit){
        return docService.list(docName, page, limit);
    }

    @PostMapping("/add")
    public Map add(@RequestBody Doc doc){
        return docService.add(doc);
    }

    @PostMapping("/renew")
    public Map renew(@RequestBody Doc doc){
        return docService.renew(doc);
    }

    @PostMapping("/remove")
    public Map remove(Long docId){
        return docService.remove(docId);
    }
}
